/* GUI CONVERTED from rescrp01.p (converter v1.75) Sat Aug 12 23:09:06 2000 */
/* rescrp01.p - REPETITIVE                                                    */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/*F0PN*/ /*K0SF*/
/*V8:ConvertMode=FullGUIReport                                                */
/* REVISION: 7.3      LAST MODIFIED: 10/31/94   BY: WUG *GN77*                */
/* REVISION: 7.3      LAST MODIFIED: 12/11/95   BY: JYM *G1FT*                */
/* REVISION: 7.3      LAST MODIFIED: 02/12/96   BY: jym *G1N8*                */
/* REVISION: 7.3      LAST MODIFIED: 04/04/96   BY: jym *G1S7*                */
/* REVISION: 8.6      LAST MODIFIED: 10/11/97   BY: bvm *K0SF*                */


/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane          */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan         */
/* REVISION: 9.1      LAST MODIFIED: 11/17/99   BY: *N04H* Vivek Gogte        */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* myb                */

/* SCRAP ANALYSIS REPORT */


/*GUI global preprocessor directive settings */
&GLOBAL-DEFINE PP_PGM_RP TRUE
&GLOBAL-DEFINE PP_ENV_GUI TRUE


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

/*G1FT*/ {mfdtitle.i "b+ "}

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE rescrp01_p_1 "Scrap!Percent"
/* MaxLen: Comment: */

&SCOPED-DEFINE rescrp01_p_2 "Scrapped Qty"
/* MaxLen: Comment: */

&SCOPED-DEFINE rescrp01_p_3 "Reason"
/* MaxLen: Comment: */

&SCOPED-DEFINE rescrp01_p_4 "Processed Qty"
/* MaxLen: Comment: */

&SCOPED-DEFINE rescrp01_p_5 "Effective"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */


/*N04H** {rewrsdef.i}                                                         */

/*G1S7*/ {revars.i}
     
     define variable dept like wc_dept.
     define variable dept1 like wc_dept label {t001.i}.
     define variable effdate as date label {&rescrp01_p_5}.
     define variable effdate1 as date label {t001.i}.
     define variable emp like op_emp.
     define variable emp1 like op_emp label {t001.i}.
     define variable line like wo_line.
     define variable line1 like wo_line label {t001.i}.
     define variable lot like wo_lot.
     define variable lot1 like wo_lot label {t001.i}.
     define variable mch like wc_mch.
     define variable mch1 like wc_mch label {t001.i}.
     define variable part like wo_part.
     define variable part1 like wo_part label {t001.i}.
     define variable reason like op_rsn.
     define variable reason1 like op_rsn label {t001.i}.
     define variable shift like op_shift.
     define variable shift1 like op_shift label {t001.i}.
     define variable site like wo_site.
     define variable site1 like wo_site label {t001.i}.
     define variable wkctr like wc_wkctr.
     define variable wkctr1 like wc_wkctr label {t001.i}.
     define variable qty_cumproc like wr_qty_cumproc
       column-label {&rescrp01_p_4}.
     define variable qty_cumscrap like wr_qty_cumoscrap
       column-label {&rescrp01_p_2}.
     define variable wrdesc like wr_desc.
     define variable ptdesc like pt_desc1.
     define variable percent_scrap as dec decimals 2 format "->,>>9.99%"
        column-label {&rescrp01_p_1}.
     define variable first_display as logical.

     
/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
        
 RECT-FRAME       AT ROW 1.4 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1   COLUMN 3 NO-LABEL
 SKIP(.1)  /*GUI*/
lot                  colon 20
        lot1                 colon 45
        part                 colon 20
        part1                colon 45
        site                 colon 20
        site1                colon 45
        line                 colon 20
        line1                colon 45
        reason               colon 20
        reason1              colon 45
        wkctr                colon 20
        wkctr1               colon 45
        mch                  colon 20
        mch1                 colon 45
        dept                 colon 20
        dept1                colon 45
        shift                colon 20
        shift1               colon 45
        emp                  colon 20
        emp1                 colon 45
        effdate              colon 20
        effdate1             colon 45
      SKIP(.4)  /*GUI*/
with frame a side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER.
 F-a-title = &IF (DEFINED(SELECTION_CRITERIA) = 0)
  &THEN " Selection Criteria "
  &ELSE {&SELECTION_CRITERIA}
  &ENDIF .
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:WIDTH-PIXELS in frame a =
  FONT-TABLE:GET-TEXT-WIDTH-PIXELS(
  RECT-FRAME-LABEL:SCREEN-VALUE in frame a + " ", RECT-FRAME-LABEL:FONT).
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5. /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



     /* SET EXTERNAL LABELS */
     setFrameLabels(frame a:handle).

/*G1FT*       {mfdtitle.i "b+ "} */

     find first gl_ctrl no-lock.

/*K0SF*/ {wbrp01.i}

        
/*GUI*/ {mfguirpa.i true  "printer" 132 }

/*GUI repeat : */
/*GUI*/ procedure p-enable-ui:

        if lot1 = hi_char then lot1 = "".
        if part1 = hi_char then part1 = "".
        if site1 = hi_char then site1 = "".
        if line1 = hi_char then line1 = "".
        if reason1 = hi_char then reason1 = "".
        if wkctr1 = hi_char then wkctr1 = "".
        if mch1 = hi_char then mch1 = "".
        if dept1 = hi_char then dept1 = "".
        if shift1 = hi_char then shift1 = "".
        if emp1 = hi_char then emp1 = "".
        if effdate = low_date then effdate = ?.
        if effdate1 = hi_date then effdate1 = ?.


/*K0SF*/ if c-application-mode <> 'web':u then
           
run p-action-fields (input "display").
run p-action-fields (input "enable").
end procedure. /* p-enable-ui, replacement of Data-Entry GUI*/

/*GUI*/ procedure p-report-quote:


/*K0SF*/ {wbrp06.i &command = update &fields = "  lot lot1 part part1 site site1
line line1 reason reason1 wkctr wkctr1 mch mch1 dept dept1 shift shift1 emp emp1 effdate
effdate1" &frm = "a"}

/*K0SF*/ if (c-application-mode <> 'web':u) or
/*K0SF*/ (c-application-mode = 'web':u and
/*K0SF*/ (c-web-request begins 'data':u)) then do:



        bcdparm = "".
        {mfquoter.i lot}
        {mfquoter.i lot1}
        {mfquoter.i part}
        {mfquoter.i part1}
        {mfquoter.i site}
        {mfquoter.i site1}
        {mfquoter.i line}
        {mfquoter.i line1}
        {mfquoter.i reason}
        {mfquoter.i reason1}
        {mfquoter.i wkctr}
        {mfquoter.i wkctr1}
        {mfquoter.i mch}
        {mfquoter.i mch1}
        {mfquoter.i dept}
        {mfquoter.i dept1}
        {mfquoter.i shift}
        {mfquoter.i shift1}
        {mfquoter.i emp}
        {mfquoter.i emp1}
        {mfquoter.i effdate}
        {mfquoter.i effdate1}

        if lot1 = "" then lot1 = hi_char.
        if part1 = "" then part1 = hi_char.
        if site1 = "" then site1 = hi_char.
        if line1 = "" then line1 = hi_char.
        if reason1 = "" then reason1 = hi_char.
        if wkctr1 = "" then wkctr1 = hi_char.
        if mch1 = "" then mch1 = hi_char.
        if dept1 = "" then dept1 = hi_char.
        if shift1 = "" then shift1 = hi_char.
        if emp1 = "" then emp1 = hi_char.
        if effdate = ? then effdate = low_date.
        if effdate1 = ? then effdate1 = hi_date.

/*K0SF*/ end.

            
/*GUI*/ end procedure. /* p-report-quote */
/*GUI - Field Trigger Section */

/*GUI MFSELxxx removed*/
/*GUI*/ procedure p-report:
/*GUI*/   {gpprtrpa.i  "printer" 132}
/*GUI*/   mainloop: do on error undo, return error on endkey undo, return error:
find first gl_ctrl no-lock.

define buffer ophist for op_hist.


        {mfphead.i}

        FORM /*GUI*/ 
        with STREAM-IO /*GUI*/  frame detail width 132 no-box down.

        /* SET EXTERNAL LABELS */
        setFrameLabels(frame detail:handle).

        for each op_hist no-lock
        where op_wo_lot >= lot and op_wo_lot <= lot1
        and op_part >= part and op_part <= part1
        and op_site >= site and op_site <= site1
        and op_line >= line and op_line <= line1
        and op_rsn >= reason and op_rsn <= reason1
        and op_wkctr >= wkctr and op_wkctr <= wkctr1
        and op_mch >= mch and op_mch <= mch1
        and op_dept >= dept and op_dept <= dept1
        and op_shift >= shift and op_shift <= shift1
        and op_emp >= emp and op_emp <= emp1
        and op_date >= effdate and op_date <= effdate1
/*G1FT*/    and op__dec01 <> 0
/*G1S7*/    and can-do(advrep_optypes,op_type)
        use-index op_date
        break by op_site by op_part by op_wo_op by op_line by op_rsn
        with width 132 no-box:
           qty_cumscrap = op__dec01.
           accumulate qty_cumscrap (sub-total by op_rsn).

           if first-of(op_line) then do:
         qty_cumproc = 0.

         do for ophist:
            for each ophist no-lock
            where op_wo_lot >= lot and op_wo_lot <= lot1
            and op_site = op_hist.op_site
            and op_part = op_hist.op_part
            and op_wo_op = op_hist.op_wo_op
            and op_line = op_hist.op_line
            and op_wkctr >= wkctr and op_wkctr <= wkctr1
            and op_mch >= mch and op_mch <= mch1
            and op_dept >= dept and op_dept <= dept1
            and op_shift >= shift and op_shift <= shift1
            and op_emp >= emp and op_emp <= emp1
            and op_date >= effdate and op_date <= effdate1
/*G1S7*/            and can-do(advrep_optypes,op_type)
/*G1N8*             use-index op_date */ :
               qty_cumproc = qty_cumproc + op_qty_comp.
            end.
         end.

         first_display = yes.
           end.

           if last-of(op_rsn)
           and (accum sub-total by op_rsn qty_cumscrap) <> 0
           then do:
         if first_display then do:
/*K0SF*           disp  **/
/*K0SF*/          display
            op_site
            op_part
            op_wo_op
            op_line
            qty_cumproc
            with frame detail STREAM-IO /*GUI*/ .

            first_display = no.
         end.

         percent_scrap =
         ((accum sub-total by op_rsn qty_cumscrap) * 100) / qty_cumproc.

         find rsn_ref where rsn_type = "scrap" and rsn_code = op_rsn
         no-lock no-error.

/*K0SF*        disp */
/*K0SF*/       display
         space(4)
         op_rsn         column-label {&rescrp01_p_3}
         rsn_desc       when (available rsn_ref)
         accum sub-total by op_rsn qty_cumscrap @ qty_cumscrap
         percent_scrap  when (percent_scrap <> ?)
         with frame detail STREAM-IO /*GUI*/ .

         down 1 with frame detail.
           end.

           if last-of(op_line) then down 1 with frame detail.

           
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/

        end.

        
/*GUI*/ {mfguitrl.i} /*Replace mfrtrail*/

/*GUI*/ {mfgrptrm.i} /*Report-to-Window*/

     end.

/*K0SF*/ {wbrp04.i &frame-spec = a}

/*GUI*/ end procedure. /*p-report*/
/*GUI*/ {mfguirpb.i &flds=" lot lot1 part part1 site site1 line line1 reason reason1 wkctr wkctr1 mch mch1 dept dept1 shift shift1 emp emp1 effdate effdate1 "} /*Drive the Report*/
